//
//  TransferDetailManagerViewController.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/21.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "TransferDetailManagerViewController.h"
#import "MyPageTabView.h"
#import "TranferTotalViewController.h"
#import "TranferNoViewController.h"
#import "TranferFinishViewController.h"



@interface TransferDetailManagerViewController ()<XXPageTabViewDelegate>
/**
 bgImg
 */
@property (nonatomic , strong) UIImageView *bgImg;
/**
 pageTableView
 */
@property (nonatomic , strong) MyPageTabView *pageTabView;
/**
 被转让的猪
 */
@property (nonatomic , strong) TranferTotalViewController *totalSaleVC;
/**
 转让记录
 */
@property (nonatomic , strong) TranferFinishViewController *finishSaleVC;

/**
 转让记录
 */
@property (nonatomic , strong) TranferNoViewController *noSaleVC;


@property (nonatomic, strong) UIView *header;

@property (nonatomic, strong) UILabel *priceLab;

@end


@implementation TransferDetailManagerViewController

#pragma mark - view life cycle

- (void)viewDidLoad {
    
    [super viewDidLoad];
    [self setUpView];
    [self initNav];
}


#pragma mark - init method

- (void)initNav {
    
    self.baseNavView.navTitleLabel.text = @"转让明细";
    self.baseNavView.navTitleLabel.textColor = KWhiteColor;
    
    UIImage *image = [UIImage imageNamed:@"meat_question_nav"];
    self.baseNavView.layer.contents =  (__bridge id)image.CGImage;
    
    [self.baseNavView.leftNavBtn setImage:[UIImage imageNamed:@"nav_white"] forState:UIControlStateNormal];
    
}


- (void)setUpView {
    [self initView];
    [self initLayout];
    [self initAction];
    [self initData];
}


- (void)initView {
    
    [self addChildViewController:self.totalSaleVC];
    [self addChildViewController:self.noSaleVC];
    [self addChildViewController:self.finishSaleVC];
    
    
    [self.view addSubview:self.header];
    [self.view addSubview:self.pageTabView];
}


- (void) initLayout {
    
    [self.header mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10 + TJ_NavBarHeight);
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(57);
    }];
    
    [self.pageTabView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.top.mas_equalTo(TJ_NavBarHeight + 67);
    }];
    
}

- (void) initAction {
    
}

- (void)initData {
    
}

#pragma mark - delegate
- (void)scrollToLast:(id)sender {
    [self.pageTabView setSelectedTabIndexWithAnimation:self.pageTabView.selectedTabIndex-1];
}


- (void)scrollToNext:(id)sender {
    [self.pageTabView setSelectedTabIndexWithAnimation:self.pageTabView.selectedTabIndex+1];
}


#pragma mark - target action
- (void)backTapped {
    //如果是从转让结果页面跳进来的   需移除对应控制器   返回到我得领养页面
    //    [self.rtNavigationController removeViewControllerWithName:@"TransferTypeViewController"];
    //    [self.rtNavigationController removeViewControllerWithName:@"TransferInfoViewController"];
    //    [self.rtNavigationController removeViewControllerWithName:@"InputTransferInfoViewController"];
    //    [self.rtNavigationController removeViewControllerWithName:@"TransferResultViewController"];
    
    [self.navigationController popViewControllerAnimated:YES];
}


- (void)transferManagerTapped {
    
}


#pragma mark - private method

#pragma mark - getter and setter


- (MyPageTabView *)pageTabView {
    if (!_pageTabView) {
        _pageTabView = [[MyPageTabView alloc] initWithChildControllers:self.childViewControllers childTitles:@[@"总售价",@"未售金额",@"已售金额"]];
        _pageTabView.backgroundColor = KWhiteColor;
        _pageTabView.subTitles = @[@"（¥2300.00）", @"（¥2300.00）", @"（¥2300.00）"];
        _pageTabView.delegate = self;
        _pageTabView.indicatorStyle = XXPageTabIndicatorStyleDefault;//跟随文本变化长度
        _pageTabView.titleStyle = XXPageTabTitleStyleDefault;//渐变
        _pageTabView.selectedTabIndex = 0;
        _pageTabView.separatorColor = [UIColor clearColor];
        _pageTabView.tabItemFont = [UIFont systemFontOfSize:15];
        _pageTabView.indicatorHeight = 2;
        _pageTabView.indicatorWidth = 26;
        _pageTabView.unSelectedColor = [UIColor colorWithHexString:@"#333333"];
        _pageTabView.selectedColor = [UIColor colorWithHexString:@"#53C203"];
        _pageTabView.tabBackgroundColor = [UIColor clearColor];
        _pageTabView.bodyBackgroundColor = [UIColor clearColor];
        _pageTabView.tabSize = CGSizeMake(KScreenWidth, 62);
        
    }
    return _pageTabView;
}

- (UIView *)header{
    
    if (!_header) {
        _header = [UIView new];
        _header.backgroundColor = KWhiteColor;
        _header.frame = CGRectMake(0, 0, KScreenWidth, 57);
        
        UIView *line = [UIView new];
        line.backgroundColor = mMainColor;
        line.frame = CGRectMake(14, (_header.height - 12)/2.0, 4, 12);
        [_header addSubview:line];
        
        UILabel *label = [UILabel makeLabelWithText:@"当前猪成本（¥3500.0）" textColor:UIColorFromRGB(0x333333) font:mFont(16) textAliment:0];
        label.size = CGSizeMake(KScreenWidth - line.right - 15, 22);
        label.mj_x = line.right + 5;
        label.mj_y = (_header.height - 22)/2.0;
        self.priceLab = label;
        [_header addSubview:label];
    }
    
    return _header;
}


- (TranferFinishViewController *) finishSaleVC{
    if (!_finishSaleVC) {
        _finishSaleVC = [[TranferFinishViewController alloc] init];
    }
    return _finishSaleVC;
}

- (TranferNoViewController *)noSaleVC {
    if (!_noSaleVC) {
        _noSaleVC = [[TranferNoViewController alloc] init];
    }
    return _noSaleVC;
}



- (TranferTotalViewController *)totalSaleVC {
    if (!_totalSaleVC) {
        _totalSaleVC = [[TranferTotalViewController alloc] init];
    }
    return _totalSaleVC;
}


@end
